package palmtop.com.palmtop.activity;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.amap.api.services.geocoder.RegeocodeResult;

import butterknife.BindView;
import butterknife.ButterKnife;
import palmtop.com.palmtop.R;
import palmtop.com.palmtop.util.Config;

public class LookmapActivity extends BaseActivity  {

    @BindView(R.id.mapViews)
    MapView mapViews;
    String latitude;
    String longitude;

    Context context;
    AMap aMap = null;
    public AMapLocationClient mLocationClient = null;
    public AMapLocationClientOption mLocationOption = null;
    Marker marker;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lookmap, Config.toptitle, 1);
        ButterKnife.bind(this);
        latitude = getIntent().getStringExtra("latitude");
        longitude = getIntent().getStringExtra("longitude");
        mapViews.onCreate(savedInstanceState);
        context = this;
        aMap = mapViews.getMap();

        if(!(TextUtils.isEmpty(latitude)||TextUtils.isEmpty(longitude))){
            LatLng ln = new LatLng(Double.valueOf(latitude), Double.valueOf(longitude));
            CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(ln, 18, 0, 0));
            aMap.moveCamera(cameraUpdate);
            marker = aMap.addMarker(new MarkerOptions().position(ln).title(""));
            marker.setIcon(BitmapDescriptorFactory.fromBitmap(BitmapFactory
                    .decodeResource(getResources(), R.mipmap.online)));
        }
    }
}
